import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;

public class 课堂训练2 {
    public static void main(String[] args) throws IOException{
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入一个整数n");
        int n = scanner.nextInt();

        int result = F(n);
        System.out.println("计算出F(n)的值为：" + result);
        File file = new File("D:\\huawei\\Javawindows文件","课堂训练.txt");
        if (!file.exists())
        {
            file.createNewFile();
        }
        String a = "输入的数为：" + n ;
        String b = "计算结果为：" + result;
        Writer writer = new FileWriter(file);
        writer.write(a);
        writer.flush();
        writer.write(b);
        writer.flush();
    }

    static int F(int n)
    {
        if (n==0)
            return 0;
        else
            if (n==1)
                return 1;
            else
                return F(n-1) + F(n-2);
    }
}
